home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1995 March / Macworld CD-ROM (March 1995).cdr / Updaters / AppMaker 1.5.2->1.5.4 / Libraries / THINK / AMClassLibC / CAMIconPane.cp < prev    next >
Encoding:
Text File  |  1991-12-04  |  2.0 KB  |  82 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.  CAMIconPane.c
  3.  
  4.         Makes an IconPane behave like a radio button.
  5.                 
  6.     SUPERCLASS = CIconPane
  7.     
  8.     Copyright © 1991 Bowers Development Corporation. All rights reserved.
  9.     
  10.  
  11. ******************************************************************************/
  12.  
  13. #include "CAMIconPane.h"
  14. #include "CLabeledGroup.h"
  15.  
  16. /******************************************************************************
  17.  IViewTemp
  18.  
  19.      Initialize from a template resource.
  20. ******************************************************************************/
  21.  
  22. void    CAMIconPane::IViewTemp    (CView            *anEnclosure,
  23.                                  CBureaucrat    *aSupervisor,
  24.                                  Ptr            viewData)
  25. {
  26.     inherited::IViewTemp (anEnclosure, aSupervisor, viewData);
  27.     isOn = FALSE;
  28.  
  29. } /* IViewTemp */
  30.  
  31. /******************************************************************************
  32.  Draw
  33.  
  34.      Draw the icon in response to an update.
  35. ******************************************************************************/
  36.  
  37. void    CAMIconPane::Draw        (Rect            *area)
  38. {
  39.     DrawIcon (isOn);
  40.  
  41. } /* Draw */
  42.  
  43.  
  44. /******************************************************************************
  45.  SetRadio
  46.  
  47.         Turn a radio icon on or off
  48. ******************************************************************************/
  49.  
  50. void    CAMIconPane::SetRadio    (Boolean        onOrOff)
  51. {
  52.     if (isOn != onOrOff) {
  53.         isOn = onOrOff;
  54.         Prepare();
  55.         DrawIcon (isOn);
  56.         
  57.         BroadcastChange (radioChanged, &onOrOff);    /* notify dependents */
  58.     }
  59.  
  60. } /* SetRadio */
  61.     
  62.  
  63. /******************************************************************************
  64.  DoClick
  65.  
  66.      Respond to a click. The wantsClicks instance variable must be
  67.      TRUE for this method ever to be called.
  68. ******************************************************************************/
  69.  
  70. void    CAMIconPane::DoClick    (Point            hitPt,
  71.                                  short            modifierKeys,
  72.                                  long            when)
  73. {
  74.     if (member (itsSupervisor, CLabeledGroup)) {
  75.         SetRadio (TRUE);
  76.         itsSupervisor->DoCommand (GetClickCmd ());
  77.     } else {
  78.         inherited::DoClick (hitPt, modifierKeys, when);
  79.     }
  80.  
  81. } /* DoClick */
  82.